package com.headline.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Created with Administrator
 * DATE:2016/11/8
 * Time:17:04
 */

@Controller
public class BaseController {
    protected HttpServletRequest request;
    protected HttpServletResponse response;
    protected HttpSession session;

    private String version = "";
    private int platform = 0;
    private int userid = 0;
    private String usertoken = "";
    private String deviceid = "";
    private String guid = "";
    private int cityid = 0;
    private int since_id = 0;
    private int max_id = 0;
    private long _timestamp;
    private String channel = "";
    private String _sign = "";

    public String getVersion() {
        return request.getParameter("version") == null ? "" : request.getParameter("version");
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public int getPlatform() {
        return Integer.parseInt(request.getParameter("platform") == null ? "0" : request.getParameter("platform"));
    }

    public void setPlatform(int platform) {
        this.platform = platform;
    }

    public int getUserid() {
        return Integer.parseInt(request.getParameter("userid") == null ? "0" : request.getParameter("userid"));
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    public String getUsertoken() {
        return request.getParameter("usertoken") == null ? "" : request.getParameter("usertoken");
    }

    public void setUsertoken(String usertoken) {
        this.usertoken = usertoken;
    }

    public String getDeviceid() {
        return request.getParameter("deviceid") == null ? "" : request.getParameter("deviceid");
    }

    public void setDeviceid(String deviceid) {
        this.deviceid = deviceid;
    }

    public String getGuid() {
        return request.getParameter("guid") == null ? "" : request.getParameter("guid");
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public int getCityid() {
        return Integer.parseInt(request.getParameter("cityid") == null ? "0" : request.getParameter("cityid"));
    }

    public void setCityid(int cityid) {
        this.cityid = cityid;
    }

    public int getSince_id() {
        return Integer.parseInt(request.getParameter("since_id") == null ? "0" : request.getParameter("since_id"));
    }

    public void setSince_id(int since_id) {
        this.since_id = since_id;
    }

    public int getMax_id() {
        return Integer.parseInt(request.getParameter("max_id") == null ? "0" : request.getParameter("max_id"));
    }

    public void setMax_id(int max_id) {
        this.max_id = max_id;
    }

    public long get_timestamp() {
        return Long.parseLong(request.getParameter("_timestamp") == null ? "0" : request.getParameter("_timestamp"));
    }

    public void set_timestamp(long _timestamp) {
        this._timestamp = _timestamp;
    }

    public String getChannel() {
        return request.getParameter("channel") == null ? "" : request.getParameter("channel");
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String get_sign() {
        return request.getParameter("_sign") == null ? "" : request.getParameter("_sign");
    }

    public void set_sign(String _sign) {
        this._sign = _sign;
    }


    @ModelAttribute
    public void setReqAndRes(HttpServletRequest request, HttpServletResponse response) {
        this.request = request;
        this.response = response;
        this.session = request.getSession();

    }


}
